﻿using System.ComponentModel;
using System.Configuration;

namespace Needle.Core.Configuration
{
    /// <summary>
    /// Defines a container configuration.
    /// </summary>
    public class ContextElement : ConfigurationElement
    {
         /// <summary>
        /// Creates a new instance
        /// </summary>
        public ContextElement()
        {
        }

        /// <summary>
        /// The name of the container.
        /// </summary>
        [ConfigurationProperty(Element.Name, IsRequired = true)]
         public string Name
        {
            get { return (string)this[Element.Name]; }
            set { this[Element.Name] = value; }
        }

        /// <summary>
        /// The object definitions.
        /// </summary>
        [ConfigurationCollection(typeof(ObjectElement))]
        [ConfigurationProperty(Element.Objects, IsDefaultCollection = true, IsRequired = true)]
        [Description("The list of configured objects")]
        public ObjectElementCollection Objects
        {
            get { return (ObjectElementCollection)this[Element.Objects]; }
        }

        /// <summary>
        /// The Container definitions.
        /// </summary>
        [ConfigurationCollection(typeof(ContextElement))]
        [ConfigurationProperty(Element.Contexts, IsDefaultCollection = false, IsRequired = false)]
        [Description("The list of child contexts")]
        public ContextElementCollection Contexts
        {
            get { return (ContextElementCollection)this[Element.Contexts]; }
        }

        /// <summary>
        /// The service definitions.
        /// </summary>
        [ConfigurationCollection(typeof(ServiceElement))]
        [ConfigurationProperty(Element.Services, IsDefaultCollection = false, IsRequired = false)]
        [Description("The list of configured services")]
        public ServiceElementCollection Services
        {
            get { return (ServiceElementCollection)this[Element.Services]; }
        }       

    }
}
